#ifndef __UTILS_H
#define __UTILS_H

#include <stdio.h>

#include "BasicTypes.h"

bool MemoryAssert(int num, ...);

/*
 *  Explination:
 * 		NAssert return NULL; should be used for functions that return pointers to memory, NULL indicating faliour.
 * 		FAssert returns FALSE/
 * 		TAssert returns TRUE if assertation failes, this is used in Main function because the FALSE
 * 		return status indicates success unlike our intention.
 * 
 * 	An M extention f.e (TAssertM) indicates allows a user to specify an error message.
 */

#define NAssert(exp)									\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		return NULL;									\
	}

#define NAssertM(exp, message)							\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		perror("with message");							\
		perror(#message);								\
		return NULL;									\
	}

#define FAssert(exp)									\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		return FALSE;									\
	}

#define FAssertM(exp, message)							\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		perror("with message");							\
		perror(#message);								\
		return FALSE;									\
	}


#define TAssert(exp)									\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		return TRUE;									\
	}

#define TAssertM(exp, message)							\
	if (!(exp))											\
	{													\
		perror("Assertation failed of " #exp " at");	\
		perror(__FILE__);								\
		perror("in function");							\
		perror(__FUNCTION__);							\
		perror("with message");							\
		perror(#message);								\
		return TRUE;									\
	}

#endif
